<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<p:dialog xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" 
	xmlns:pe="http://primefaces.org/ui/extensions"
	modal="true" width="620" height="500" resizable="false" 
	widgetVar="dialogListPais" id="listDialogPais"
	appendToBody="true" >
	
	<link type="text/css" rel="stylesheet" href="../../resources/css/style.css" />
	
	<f:facet name="header">
		<h:outputText value="Consultar País"/>
	</f:facet>
	
	<h:form id="formListPais">
		<div style="margin-left:5%;">
			<p:messages autoUpdate="true"/>
			<h:panelGrid columns="8">
				<h:outputText value="Filtrar por:" />
								
				<p:inputText id="inputSearchFilterCod" style="width:50px;" value="#{vendaBean.filterId}" title="Código" maxlength="15">
					<pe:keyFilter regEx="/[\d]/" />
				</p:inputText>
				<p:watermark value="Código" for="inputSearchFilterCod"/>
				
				<p:inputText id="inputSearchFilterPais" style="width:250px;" value="#{vendaBean.filter}" title="País" maxlength="50"/>
				<p:watermark value="País" for="inputSearchFilterPais"/>
				
				<p:commandButton icon="ui-icon-search" style="height:24px;" title="Consultar" id="searchPais" update="@form" actionListener="#{vendaBean.fillPaisByFilter}"/>
				<p:commandButton icon="ui-icon-plus" style="height:24px;" title="Novo" actionListener="#{vendaBean.openDialogAddPais}"/>
				<p:commandButton icon="ui-icon-check" title="Selecionar" actionListener="#{vendaBean.addPais}" process="@this formListPais" update="formListPais" style="height:24px;"/>
			</h:panelGrid>
		
			<div style="float:left; padding-top:10px;">
				<p:dataTable id="tableListPais" value="#{vendaBean.paises}"
					var="pais" selectionMode="single" style="width:545px" 					
					selection="#{vendaBean.selectedPais}" rowKey="#{pais.id}"
					paginator="true" rows="10" paginatorPosition="bottom"
					emptyMessage="Não há registros"> 
					 					
					<p:ajax event="rowDblselect" listener="#{vendaBean.addPais}"/>
					
			        <p:column headerText="Código" width="50">  
			            <h:outputText value="#{pais.id}" />  
			        </p:column>			  
			        
			        <p:column headerText="País">  
			            <h:outputText value="#{pais.pais}" />  
			        </p:column> 
			        
			        <p:column headerText="Sigla" width="50">
						<h:outputText value="#{pais.sigla}" />
					</p:column>

					<p:column headerText="DDI" width="50">
						<h:outputText value="#{pais.ddi}" />
					</p:column>
					
					<p:column width="10">
						<p:commandButton icon="ui-icon-check" title="Selecionar" actionListener="#{vendaBean.addPais(pais.id)}" style="height:24px; width:24px;"/>
					</p:column>
		  	  </p:dataTable>
			</div>
		</div>
	</h:form>
</p:dialog>